//设置多个图片翻页操作
function showAllPageLinks() { //设置翻页按钮
	let llen = window.g_batch.data.length

	$('#showPages').show()
	$('#showPages ul li[data="my"]').hide()

	$(`#showPages ul li[data="my"]:lt(${llen})`).show()

	SetPageActive()
}

function SetPageActive() { //设置当前页码按钮Active
	let current = window.g_batch.index
	$('#showPages ul li[data="my"]').removeClass('active').eq(current).addClass('active')
}


// 初始化3个按钮
$(function() {
	//$('#showPages ul li:last-child').click(function() {
	$('#showPages ul').on('click', 'li:last-child', function() {
		if (window.g_batch.index < window.g_batch.data.length - 1) {
			setResultByIndex(window.g_batch.index + 1)

			SetPageActive()
			showCanvasBoxNumber()
		}
	});

	//$('#showPages ul li:first-child').click(function() {
	$('#showPages ul').on('click', 'li:first-child', function() {
		if (window.g_batch.index > 0) {
			setResultByIndex(window.g_batch.index - 1)
			SetPageActive()
			showCanvasBoxNumber()
		}
	});

	//$('#showPages ul li[data="my"]').click(function() {
	$('#showPages ul').on('click', 'li[data="my"]', function() {
		let page = Number($(this).find('a').text());
		if (isNaN(page)) {
			bootbox.alert({
				title: "出错",
				message: "显示图片出错，请重新尝试！",
				size: 'small'
			});
			return
		}
		setResultByIndex(page - 1)
		SetPageActive()
		showCanvasBoxNumber()
	});
})


$(function() { //设置数量修改保存
	$('#health, #oneleaf, #partial').on('change', function() {
		//console.log('WWWWWWWW:')
		if (!window.g_data) {
			console.log('没有数据2');
			return;
		}
		window.g_data.changeNum = {
			health: $('#health').val(),
			oneleaf: $('#oneleaf').val(),
			partial: $('#partial').val(),
			seeds: $('#health').val() + $('#oneleaf').val()
		}
		//console.log('save:', window.g_data.changeNum )
	})
})
